package cn.edu.ustc.xrovers.action;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import cn.edu.ustc.xrovers.model.Company;
import cn.edu.ustc.xrovers.service.HandleCompanyInfoService;

import com.opensymphony.xwork2.ActionSupport;

/**
 * 添加公司信息的action
 * 包括公司基本信息、财务报表信息、非财务信息
 * @author paddy
 *
 */
public class CoBaseInfoAction extends ActionSupport {

	private static final String GUARANTOR="guarantor";//担保方
	private static final String DEBIT="debit";//借方
	private static final String BOTH="both";//既是担保方也是借方
	private Company company;
	private HandleCompanyInfoService hci;
	
	/**
	 * 保存借款企业基本信息
	 */
	public String insertCoBaseInfo() throws Exception {
		HttpSession session=ServletActionContext.getRequest().getSession();
		boolean flag=hci.saveCoBaseInfo(session, company,DEBIT);
		if(flag)
			return SUCCESS;
		else
			return INPUT;
	}
	
	/**
	 * 保存担保企业的基本信息
	 * @return
	 * @throws Exception
	 */
	public String insertGuaBaseInfo() throws Exception {
		HttpSession session=ServletActionContext.getRequest().getSession();
		boolean flag=hci.saveGuaBaseInfo(session,company, GUARANTOR);
		if(flag)
			return SUCCESS;
		else
			return INPUT;
	}

	/*getset方法*/
	public Company getCompany() {
		return company;
	}
	public void setCompany(Company company) {
		this.company = company;
	}
	public void setHci(HandleCompanyInfoService hci) {
		this.hci = hci;
	}
	public HandleCompanyInfoService getHci() {
		return hci;
	}
}
